package com.atguigu.ssyx.payment.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 *
 */
@Component
@ConfigurationProperties(prefix = "weixin")
public class ConstantPropertiesUtils implements InitializingBean {


    private String appid;

    private String partner;

    private String partnerkey;

    private String notifyurl;

    private String cert;

    public static String APPID;
    public static String PARTNER;
    public static String PARTNERKEY;
    public static String NOTIFYURL;
    public static String CERT;

    // Getter and Setter methods
    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String getPartner() {
        return partner;
    }

    public void setPartner(String partner) {
        this.partner = partner;
    }

    public String getPartnerkey() {
        return partnerkey;
    }

    public void setPartnerkey(String partnerkey) {
        this.partnerkey = partnerkey;
    }

    public String getNotifyurl() {
        return notifyurl;
    }

    public void setNotifyurl(String notifyurl) {
        this.notifyurl = notifyurl;
    }

    public String getCert() {
        return cert;
    }

    public void setCert(String cert) {
        this.cert = cert;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("=== 微信支付配置加载 ===");
        System.out.println("appid: " + appid);
        System.out.println("partner: " + partner);
        System.out.println("partnerkey: " + partnerkey);
        System.out.println("notifyurl: " + notifyurl);
        System.out.println("cert: " + cert);
        
        APPID = appid;
        PARTNER = partner;
        PARTNERKEY = partnerkey;
        NOTIFYURL = notifyurl;
        CERT = cert;
        
        System.out.println("=== 静态变量设置 ===");
        System.out.println("APPID: " + APPID);
        System.out.println("PARTNER: " + PARTNER);
        System.out.println("PARTNERKEY: " + PARTNERKEY);
        System.out.println("NOTIFYURL: " + NOTIFYURL);
        System.out.println("CERT: " + CERT);
    }
}
